home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / com_net / tcp / amitcp / netinclude / netinet / in.h < prev    next >
C/C++ Source or Header  |  2000-01-01  |  7KB  |  202 lines

  1. /*
  2.  * $Id: in.h,v 1.6 1993/06/04 11:16:15 jraja Exp $
  3.  *
  4.  * HISTORY
  5.  * $Log: in.h,v $
  6.  * Revision 1.6  1993/06/04  11:16:15  jraja
  7.  * Fixes for first public release.
  8.  *
  9.  * Revision 1.5  1993/04/13  22:07:58  jraja
  10.  * Added inclusion of sys/param.h, which include htons() et al, since many
  11.  * BSD programs think that they should be included from here.
  12.  *
  13.  * Revision 1.4  93/03/06  02:14:28  02:14:28  jraja (Jarno Tapio Rajahalme)
  14.  * Made INADDR_ANY visible in AmiTCP even in KERNEL, since library functions
  15.  * need it.
  16.  * 
  17.  * Revision 1.3  93/03/03  22:07:51  22:07:51  jraja (Jarno Tapio Rajahalme)
  18.  *  Changed explicit prototypes back.
  19.  * 
  20.  * Revision 1.2  93/03/03  21:55:25  21:55:25  jraja (Jarno Tapio Rajahalme)
  21.  * Added #ifndef to prevent multiple inclusion.
  22.  * 
  23.  * Revision 1.1  92/11/17  16:47:45  16:47:45  jraja (Jarno Tapio Rajahalme)
  24.  * Initial revision
  25.  * 
  26.  *
  27.  */
  28.  
  29. /*
  30.  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
  31.  * All rights reserved.
  32.  *
  33.  * Redistribution and use in source and binary forms, with or without
  34.  * modification, are permitted provided that the following conditions
  35.  * are met:
  36.  * 1. Redistributions of source code must retain the above copyright
  37.  *    notice, this list of conditions and the following disclaimer.
  38.  * 2. Redistributions in binary form must reproduce the above copyright
  39.  *    notice, this list of conditions and the following disclaimer in the
  40.  *    documentation and/or other materials provided with the distribution.
  41.  * 3. All advertising materials mentioning features or use of this software
  42.  *    must display the following acknowledgement:
  43.  *    This product includes software developed by the University of
  44.  *    California, Berkeley and its contributors.
  45.  * 4. Neither the name of the University nor the names of its contributors
  46.  *    may be used to endorse or promote products derived from this software
  47.  *    without specific prior written permission.
  48.  *
  49.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59.  * SUCH DAMAGE.
  60.  *
  61.  *    @(#)in.h    7.11 (Berkeley) 4/20/91
  62.  */
  63.  
  64. #ifndef IN_H
  65. #define IN_H
  66.  
  67. /*
  68.  * Macros for network/external number representation conversion.
  69.  */
  70. #ifndef ntohl
  71. #define    ntohl(x)    (x)
  72. #define    ntohs(x)    (x)
  73. #define    htonl(x)    (x)
  74. #define    htons(x)    (x)
  75.  
  76. #define    NTOHL(x)    (x)
  77. #define    NTOHS(x)    (x)
  78. #define    HTONL(x)    (x)
  79. #define    HTONS(x)    (x)
  80. #endif
  81.  
  82. /*
  83.  * Constants and structures defined by the internet system,
  84.  * Per RFC 790, September 1981.
  85.  */
  86.  
  87. /*
  88.  * Protocols
  89.  */
  90. #define    IPPROTO_IP        0        /* dummy for IP */
  91. #define    IPPROTO_ICMP        1        /* control message protocol */
  92. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  93. #define    IPPROTO_TCP        6        /* tcp */
  94. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  95. #define    IPPROTO_PUP        12        /* pup */
  96. #define    IPPROTO_UDP        17        /* user datagram protocol */
  97. #define    IPPROTO_IDP        22        /* xns idp */
  98. #define    IPPROTO_TP        29         /* tp-4 w/ class negotiation */
  99. #define    IPPROTO_EON        80        /* ISO cnlp */
  100.  
  101. #define    IPPROTO_RAW        255        /* raw IP packet */
  102. #define    IPPROTO_MAX        256
  103.  
  104.  
  105. /*
  106.  * Local port number conventions:
  107.  * Ports < IPPORT_RESERVED are reserved for
  108.  * privileged processes (e.g. root).
  109.  * Ports > IPPORT_USERRESERVED are reserved
  110.  * for servers, not necessarily privileged.
  111.  */
  112. #define    IPPORT_RESERVED        1024
  113. #define    IPPORT_USERRESERVED    5000
  114.  
  115. /*
  116.  * Internet address (a structure for historical reasons)
  117.  */
  118. struct in_addr {
  119.     u_long s_addr;
  120. };
  121.  
  122. /*
  123.  * Definitions of bits in internet address integers.
  124.  * On subnets, the decomposition of addresses to host and net parts
  125.  * is done according to subnet mask, not the masks here.
  126.  */
  127. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  128. #define    IN_CLASSA_NET        0xff000000
  129. #define    IN_CLASSA_NSHIFT    24
  130. #define    IN_CLASSA_HOST        0x00ffffff
  131. #define    IN_CLASSA_MAX        128
  132.  
  133. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  134. #define    IN_CLASSB_NET        0xffff0000
  135. #define    IN_CLASSB_NSHIFT    16
  136. #define    IN_CLASSB_HOST        0x0000ffff
  137. #define    IN_CLASSB_MAX        65536
  138.  
  139. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  140. #define    IN_CLASSC_NET        0xffffff00
  141. #define    IN_CLASSC_NSHIFT    8
  142. #define    IN_CLASSC_HOST        0x000000ff
  143.  
  144. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  145. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  146.  
  147. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xe0000000) == 0xe0000000)
  148. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  149.  
  150. #define    INADDR_ANY        (u_long)0x00000000
  151. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  152. #if !defined(KERNEL) || defined(AMITCP)
  153. #define    INADDR_NONE        0xffffffff        /* -1 return */
  154. #endif
  155.  
  156. #define    IN_LOOPBACKNET        127            /* official! */
  157.  
  158. /*
  159.  * Socket address, internet style.
  160.  */
  161. struct sockaddr_in {
  162.     u_char    sin_len;
  163.     u_char    sin_family;
  164.     u_short    sin_port;
  165.     struct    in_addr sin_addr;
  166.     char    sin_zero[8];
  167. };
  168.  
  169. /*
  170.  * Structure used to describe IP options.
  171.  * Used to store options internally, to pass them to a process,
  172.  * or to restore options retrieved earlier.
  173.  * The ip_dst is used for the first-hop gateway when using a source route
  174.  * (this gets put into the header proper).
  175.  */
  176. struct ip_opts {
  177.     struct    in_addr ip_dst;        /* first hop, 0 w/o src rt */
  178.     char    ip_opts[40];        /* actually variable in size */
  179. };
  180.  
  181. /*
  182.  * Options for use with [gs]etsockopt at the IP level.
  183.  * First word of comment is data type; bool is stored in int.
  184.  */
  185. #define    IP_OPTIONS    1    /* buf/ip_opts; set/get IP per-packet options */
  186. #define    IP_HDRINCL    2    /* int; header is included with data (raw) */
  187. #define    IP_TOS        3    /* int; IP type of service and precedence */
  188. #define    IP_TTL        4    /* int; IP time to live */
  189. #define    IP_RECVOPTS    5    /* bool; receive all IP options w/datagram */
  190. #define    IP_RECVRETOPTS    6    /* bool; receive IP options for response */
  191. #define    IP_RECVDSTADDR    7    /* bool; receive IP dst addr w/datagram */
  192. #define    IP_RETOPTS    8    /* ip_opts; set/get IP per-packet options */
  193.  
  194. #ifdef KERNEL
  195. struct in_addr in_makeaddr(u_long net,
  196.                            u_long host);
  197. u_long in_netof(struct in_addr in);
  198. u_long in_lnaof(struct in_addr in);
  199. #endif
  200.  
  201. #endif /* !IN_H */
  202.